package com.jcl.cloud.services.crawler.brain.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jcl.cloud.services.brain.common.dto.BuyResumeDataModel;
import com.jcl.cloud.services.crawler.brain.task.ExecuteBuyResumeHandler;
import com.jcl.cloud.services.gateway.common.task.BuyResumeReq;
import redis.clients.jedis.Jedis;

public class TestJedis {

    public static void main(String[] args) {
        Jedis jedis = new Jedis("47.99.122.102",8080);

        String str = jedis.rpop("unicrawler:buy-resume:tasks");

        JSONObject jo = JSON.parseObject(str);

        JSONObject dataJO = jo.getJSONObject("data");

        String crawlerId = jo.getString("crawlerId");
        String taskIdForBuy = jo.getString("taskIdForBuy");
        String tenantId = jo.getString("tenantId");


        BuyResumeReq buyResumeReq = JSON.toJavaObject(dataJO,BuyResumeReq.class);

// Map map = JSON.toJavaObject(JSON.parseObject(buyResumeData),HashMap.class);
        BuyResumeDataModel buyResumeDataModel = new BuyResumeDataModel();

        buyResumeDataModel.setTaskIdForBuy(taskIdForBuy);
        buyResumeDataModel.setCrawlerId(crawlerId);
        buyResumeDataModel.setTenantId(tenantId);
        //BuyResumeReq buyResumeReq = JSON.toJavaObject(JSON.parseObject((String) map.get("data")),BuyResumeReq.class);
        buyResumeDataModel.setBuyResumeContext(buyResumeReq.getBuyResumeContext());
        buyResumeDataModel.setTaskType(buyResumeReq.getTaskType());


        ExecuteBuyResumeHandler executeBuyResumeHandler = new ExecuteBuyResumeHandler();


        executeBuyResumeHandler.executeBuy(buyResumeDataModel);
    }
}
